<template>

        <ul class="adList">
            <van-checkbox-group ref="checkboxGroup" v-if="lists.length>0">
                <li v-for="dt in lists" :key="dt.adPlaceJobRecordId" @click="getFxData(dt)">
                    <div class="item img" v-if="dt.adUrl">
                        <Images :url='dt.adUrl'/>
                    </div>
                    <div class="item name">
                        <h5>{{dt.adPlaceTitle}}</h5>
                        <p><span v-t="'analysis.title9'">Cumulative reward: </span> <em>{{dt.totalCxt.decimalTwoString}}CXT</em></p>
                    </div>
                    <div class="item">
                        <p v-t="'analysis.title4'">UV</p>
                        <h5><em>{{dt.totalUv}}</em></h5>
                    </div>
                    <div class="item">
                        <p v-t="'analysis.title5'">PV</p>
                        <h5><em>{{dt.totalPv}}</em></h5>
                    </div>
                </li>
            </van-checkbox-group>
            <div class="nomyads" v-else v-t="'dataNo'">No Data</div>
        </ul>

</template>

<script>
import { reactive,toRefs,getCurrentInstance,computed ,onMounted} from 'vue'
import {useRoute,useRouter} from 'vue-router'
import { useStore } from 'vuex'
import Images from '@/components/image.vue'
import { useI18n } from 'vue-i18n'

export default {
    components:{
     Images
    },
    props:{

    },
    setup(props,context){
        const router = useRouter()
        const route = useRoute()
        const store = useStore()
        const {proxy} = getCurrentInstance()
        const {t} = useI18n()

        const state = reactive({
            userInfo:computed(()=>store.state.base.userInfo),
            lists:[]
        })
        onMounted(()=>{
            getList()
        })

        const getList = async (checked)=>{
            const res = await store.dispatch("ad/my_release_ads_list", {
                page: 1,
                limit: 100,
                //adPlaceJobStatus:2,
                orderField: "",
                orderType: "",
                rankType:1,
                walletAddress: state.userInfo.walletAddress
            });
            state.lists = res.data
            if(res.data && res.data.length>0){
                //const {adPlaceJobRecordId,adPlaceId} = res.data[0].adPlaceJobRecordId
                context.emit('getData',res.data[0])
            }
        }

        

        const getFxData = (item)=>{
            //const {adPlaceJobRecordId,adPlaceId} = item
            context.emit('getData',item)
        }

        return{
            ...toRefs(state),
            getFxData
        }
    }
}
</script>

<style lang="scss" scoped>

    .adList{
        flex: 1;
        padding: 0;
        margin: 0;
        list-style: none;
        overflow: hidden;
        overflow-y: auto;
        font-family: Inter-Medium, Inter;
        font-weight: 500;
        color: #FFFFFF;
        font-size: 22px;
        line-height: normal;
        li{
            display: flex;
            height: 100px;
            position: relative;
            z-index: 10;
            &::after{
                content: '';
                position: absolute;
                z-index: 10;
                left: 0;
                bottom: 0;
                width: 100%;
                height: 1px;
                background: rgba(103,248,255,0.2000);
            }
            &:first-child{
                &::before{
                    content: '';
                    position: absolute;
                    z-index: 10;
                    left: 0;
                    top: 0;
                    width: 100%;
                    height: 1px;
                    background: rgba(103,248,255,0.2000);
                }
            }
            .item{
                overflow: hidden;
                line-height: 40px;
                padding: 12px 10px 0 10px;
                text-align: center;
                &.name{
                    flex: 1;
                    padding-left: 0;
                    text-align: left;
                }
                &.time{
                    padding-right: 0;
                    p{
                        color: #fff;
                        text-align: right;
                        &+p{
                            padding: 3px 0 0 0;
                        }
                    }
                }
                &.img{
                    height: 100%;
                    width: 90px;
                    padding:15px 15px 15px 0;
                }
                h5{
                    font-family: Inter-Medium, Inter;
                    font-weight: 500;
                    width: 100%;
                    padding: 0 0 0 0;
                    margin: 0;
                    font-size: 22px;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                    overflow: hidden;
                    word-break: break-all;
                }
                p{
                    font-family: Inter-Medium, Inter;
                    font-weight: 500;
                    padding: 0;
                    margin: 0;
                    color: rgba(255,255,255,0.5000);
                    font-size: 22px;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                    overflow: hidden;
                    word-break: break-all;
                }
                em{
                    font-size: 22px;
                    color: #67F8FF;
                    font-style: normal;
                    font-weight: 500;
                }
            }
        }
    }
    .nomyads{
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 22px;
        color: #FFFFFF;
        font-family: Inter-Medium, Inter;
        font-weight: 500;
        padding: 100px 0 0 0;
    }
 
 
</style>